{block #mainTitle}Zboží{/block}
{block #content}
<div id="dialog-confirm" style="display:none;">
    <p>
        <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;">
        </span>Opravdu si přejete položku trvale odstranit?
    </p>
</div>

<div id="breadcrumb">
    <span class="breadcrumb">Zboží</span>
</div>

<a class="button-add" href="{link Zbozi:pridat}">Přidat</a>
<table class="data-table" n:if="count($tiles)">
    <thead>
        <tr>
            <th>Výrobce</th>
            <th>Kód</th>
            <th>Typ</th>
            <th>Rozměr</th>
            <th>Cena</th>
            <th>V kóji</th>
            <th>Akce</th>
        </tr>
    </thead>
    <tbody>        
        <tr n:foreach="$tiles as $tile" {if $tile->action}class="highlighted"{/if}>            
            <td>{$tile->manufacturer->title}</td>
            <td>{$tile->code}</td>
            <td>{$tile->type->title}</td>            
            <td>{$tile->width} cm x {$tile->height} cm</td>
            <td>{$tile->price|number:2:',':' '} Kč/{$tile->type->unit}</td>
            <td>{foreach $tile->related('showroom_has_tiles') as $showroomTile}{$showroomTile->showroom->title}{/foreach}</td>
            <td>
                <a class="action-icon-edit" href="{link upravit $tile->id_tile}">upravit</a>
                {if $tile->action}
                    <a class="ajax action-icon-minus" href="{link odebrat! $tile->id_tile}">odebrat z akcí</a>
                {else}
                    <a class="ajax action-icon-plus" href="{link pridat! $tile->id_tile}">přidat do akcí</a>
                {/if}
                <a class="action-icon-delete" href="{link smazat! $tile->id_tile}">smazat</a>
            </td>
        </tr>        
    </tbody>
    <script type="text/javascript">
        initButtons();
        initAjaxLinks();
        
        $(function() {
            $(".action-icon-delete").bind('click', showModal);
            function showModal() {
                var link = this.href;                
                $('#dialog-confirm').dialog({
                        modal: true,
                        closeText: 'zavřít',
                        title: 'Smazání položky',
                        buttons: {
                            'Ano':function(event) {
                                event.preventDefault();
                                $.get(link);
                                $(this).dialog('close');
                            },
                            'Ne': function() {
                                $(this).dialog('close');
                            }
                        }
                });
                return false;
            };
        });
    </script>
</table>
{/block}
